package com.topdt.jbpm.web;

import com.thx.web.UserContextUtil;
import com.topdt.jbpm.identity.User;

/**
 * web环境下，会话用户的工具类
 *
 * @author balancejia
 *
 */
public class SessionUserUtil {

	public static User getCurrentUser() {
		com.thx.auth.User user = UserContextUtil.getUser();

		UserImpl ui = new UserImpl();

		ui.setEmail("");
		ui.setId(user.getUserId());
		ui.setPhoneNumber("");
		ui.setName(user.getUsername());

		return ui;
	}

	static class UserImpl implements User {

		/**
		 *
		 */
		private static final long serialVersionUID = 1L;
		private String id;
		private String name;
		private String email;
		private String phoneNumber;

		public void setId(String id) {
			this.id = id;
		}

		public void setName(String name) {
			this.name = name;
		}

		public void setEmail(String email) {
			this.email = email;
		}

		public void setPhoneNumber(String phoneNumber) {
			this.phoneNumber = phoneNumber;
		}

		@Override
		public String getId() {
			return id;
		}

		@Override
		public String getName() {
			return name;
		}

		@Override
		public String getPhoneNumber() {
			return phoneNumber;
		}

		@Override
		public String getEmail() {
			return email;
		}

	}
}
